Page({
  /**
   * 页面的初始数据
   */
  data: { 
      headImg: "https://wx.qlogo.cn/mmopen/vi_32/Q0j4TwGTfTLcuf8LczicWQuria3icQe7CTLBzR7ru1b3RfFqz2IKydBW5arSaugJ9vPlqDE0YlXRicq6HGmIcDdb1A/132",
      nickName : "Boom~"
    ,
    //四个按钮的数据
    meIconTitles: ["我的投资", "回款日历", "银行卡", "资金明细"],
    meIconImgs: [
      "../../imgs/rnol_home/rnol_home_icon001@2x.png",
      "../../imgs/rnol_home/rnol_home_icon002@2x.png",
      "../../imgs/rnol_home/rnol_home_icon003@2x.png",
      "../../imgs/rnol_home/rnol_home_icon004@2x.png"
    ],
    list_items : [
      {"name": "我要借款","index": 0,"group" : false,"icon":""},
      { "name": "债权转让", "index": 1, "group": false, "icon": "" },
      { "name": "自动投标", "index": 2, "group": true, "icon": "" },
      { "name": "我的好友", "index": 3, "group": false, "icon": "" },
      { "name": "我的奖励", "index": 4, "group": false, "icon": "" },
      { "name": "我的礼品", "index": 5, "group": false, "icon": "" },
      { "name": "系统设置", "index": 6, "group": false, "icon": "" },

    ]
  },
  //换头像
  changeHeaderAction : function(){
    var that = this;
    wx.chooseImage({
      count: 1, // 默认9
      sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图，默认二者都有
      sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机，默认二者都有
      success: function (res) {
        console.log(res);
        that.setData({
          headImg: res.tempFilePaths,
          nickName: "霸绝天下"
        })
      }
    })

  },

//列表点击回调
  indexClickAction: function (event){
    var index = event.currentTarget.dataset.index;
    console.log(index)

  },

  onGotUserInfo: function (e) {//获取用户信息
    console.log(e.detail.errMsg)
    console.log(e.detail.userInfo)
    console.log(e.detail.rawData)
    // this.userInfo = e.detail.userInfo;
    var that = this;
    that.setData({
      headImg: e.detail.userInfo.avatarUrl,
      nickName: e.detail.userInfo.nickName
    })
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    wx.setNavigationBarTitle({
      title: '我的',
    });

    var that = this;
    wx.getUserInfo({
      success: res => {
        // 可以将 res 发送给后台解码出 unionId
        that.userInfo = res.userInfo
      }
    })

  },


  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
    
    
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
    
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
    
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
    
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
    
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
    
  }
})